package com.bank.backend.boot.server.controller;

import com.bank.backend.boot.base.model.dto.AccountDTO;
import com.bank.backend.boot.base.model.vo.AccountVO;
import com.bank.backend.boot.server.annotation.ResponseResult;
import com.bank.backend.boot.server.service.AccountService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author jiaowei
 * @since 2025/3/30 14:45
 */
@Slf4j
@Tag(name = "账户信息")
@RestController
@RequestMapping("/account")
public class AccountController {
    @Resource
    private AccountService accountService;

    @Operation(summary = "保存账户信息")
    @PostMapping("/saveAccount")
    @ResponseResult
    public Boolean saveAccount(@RequestBody AccountDTO accountDTO) {
        return accountService.saveAccount(accountDTO);
    }

    @Operation(summary = "根据账户id查询账户信息")
    @GetMapping("/queryAccountById/{id}")
    @ResponseResult
    public AccountVO queryAccountById(@PathVariable(value = "id") Long id) {
        return accountService.queryAccountById(id);
    }

    @Operation(summary = "根据用户id查询账户信息")
    @GetMapping("/queryAccountListByUid/{uid}")
    @ResponseResult
    public List<AccountVO> queryAccountListByUid(@PathVariable(value = "uid") Long uid) {
        return accountService.queryAccountListByUid(uid);
    }

    @Operation(summary = "查询账户信息（分页）")
    @GetMapping("/queryAccountPage/{current}/{pageSize}")
    @ResponseResult
    public Page<AccountVO> queryAccountPage(@PathVariable("current") int current, @PathVariable("pageSize") int pageSize) {
        log.warn("查询账户信息入参：current:{},pageSize:{}", current, pageSize);
        return accountService.queryAccountPage(current, pageSize);
    }

    @Operation(summary = "查询账户信息")
    @GetMapping("/queryAccountList")
    @ResponseResult
    public List<AccountVO> queryAccountList() {
        return accountService.queryAccountList();
    }
}
